#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>

using namespace std;

int rob1(const vector<int>& nums, int left, int right)
{
    if (left > right)
        return 0;
    int n = nums.size();
    vector<int> f(n + 10, 0);
    auto g = f;

    f[left] = nums[left];
    for (int i = left + 1; i <= right; ++i)
    {
        f[i] = nums[i] + g[i - 1];
        g[i] = max(f[i - 1], g[i - 1]);
    }

    return max(f[right], g[right]);
}

int rob(const vector<int>& nums) {
    int n = nums.size();
    return max(nums[0] + rob1(nums, 2, n - 1), rob1(nums, 1, n));
}


int main()
{
    rob({1,2,3});
	return 0;
}